<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class mprogram extends MY_Model {

    var $theme_data = array(
        'layout_main' => 'layout',
        'left' => 'include/leftcp',
    );
    public $mytable = "program";
    public $primaryKey = "PROG_ID";
    public $resCode = "PROGRAM";

    function __construct() {
        parent::__construct();
    }

    function field() {
		$fieldData = array();
		$fieldData['CAT_ID'] = 0;
		$fieldData['COU_ID'] = 0;
		$fieldData['PROG_TITLE'] = '';
		$fieldData['PROG_CODE'] = '';
		$fieldData['PROG_DESCRIPTION'] = '';
		$fieldData['PROG_ORDER'] = 0;
		$fieldData['PROG_STATUS'] = 0;
		$fieldData['SEO_H1'] = '';
		$fieldData['SEO_DESCRIPTION'] = '';
		$fieldData['SEO_METATITLE'] = '';
		$fieldData['SEO_KEYWORD'] = '';
		$fieldData['PROG_THUMB'] = '';
		$fieldData['PROG_TIMEUPDATE'] = 0;
		$fieldData['PROG_TIMECREATE'] = 0;
		$fieldData['PROG_COVER'] = '';
		return $fieldData;
    }
	
	function reload_cache(){
		$this->load->helper('file');
		
		$programs = $this->mprogram->gets();
		$data_temp =array();
		$data = "<?php \n";
        $data.="return ";
		if($programs) {
			foreach($programs as $program){
			if($program->PROG_CODE != '')
				$data_temp[] = strtolower($program->PROG_CODE);
			}
		$data_temp = var_export($data_temp, true);
		$data.= $data_temp;
        $data.="?>\n";
        write_file('./mcache/program_router.php', $data);
		}
	
	}
}

?>